package com.yinhe.music.yhmusic.dialog;

import android.content.Context;
import android.content.Intent;
import android.support.annotation.NonNull;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import com.dou361.dialogui.DialogUIUtils;
import com.dou361.dialogui.bean.BuildBean;
import com.yinhe.music.yhmusic.R;
import com.yinhe.music.yhmusic.model.Music;
import com.yinhe.music.yhmusic.personal.BuyMusicActivity;
import com.yinhe.music.yhmusic.personal.vip.MyVipActivity;

/**
 * 创建歌单弹窗
 */
public class BuyDialog {


    private Context mContext;
    private BuildBean mDialog;
    private Music mMusic;

    public BuyDialog(@NonNull Context context, Music music) {
        mContext = context;
        mMusic = music;
        init();
    }

    public void show() {
        if (mDialog != null) {
            mDialog.show();
        }
    }


    public  void init() {
        View view = View.inflate(mContext, R.layout.dialog_buy, null);
        mDialog = DialogUIUtils.showCustomAlert(mContext, view);
        TextView textView = view.findViewById(R.id.buy_music);
        Button button = view.findViewById(R.id.open_vip);
        button.setOnClickListener((v) -> {
            mContext.startActivity(new Intent(mContext, MyVipActivity.class));
            DialogUIUtils.dismiss(mDialog);
        });

        textView.setOnClickListener((v) -> {
            Intent intent = new Intent(mContext, BuyMusicActivity.class);
            intent.putExtra("music", mMusic);
            mContext.startActivity(intent);
            DialogUIUtils.dismiss(mDialog);
        });
    }
}
